import { Size } from 'cc';
import { screen } from 'cc';
import { view } from 'cc';
import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('canvas')
export class canvas extends Component {
    start() {
        view.on('canvas-resize',this.updateAdapter,this)
    }
    updateAdapter() {
        // 当前浏览器视口（屏幕可见）的宽高【单位px】 screen.windowSize.width/height
        // 缩放比例（视口高度项目中与实际高度的比）
        // cocos中实际宽高 视口宽高/缩放比例
        let winSize = new Size(screen.windowSize.width / view["_scaleX"], screen.windowSize.height / view["_scaleY"])
        console.log('实际高度：' + winSize.width + ' ' + winSize.height)
        if(winSize.width > winSize.height){
            console.log('横屏模式')
        }else{
            console.log('竖屏模式')
            // this.node.po
        }
    }
    update(deltaTime: number) {
        
    }
}


